// src/services/visualSceneService.js (新建文件)
import api from './api';

const visualSceneService = {
  /**
   * 向后端请求生成场景图片
   * @param {string} description 场景描述
   * @returns {Promise<string>} 返回图片的Base64编码
   */
  async generateScene(description) {
    try {
      const response = await api.post('/api/scenes/generate', { description });
      if (response.data && response.data.image) {
        return response.data.image;
      } else {
        throw new Error(response.data.error || '未能获取到生成的图片');
      }
    } catch (error) {
      const errorMessage = error.response?.data?.error || error.message || '场景生成失败';
      throw new Error(errorMessage);
    }
  }
};

export default visualSceneService;